<html>
    <head>
        <title>Welcome to ${message(code: "default.title")}</title>
		<meta name="layout" content="main" />
    </head>
    <body>
		<g:render template="/shared/navigation" />
		
		<div id="body">
	        <h1>Welcome to ${message(code: "default.title")}</h1>
	        
		    <g:if test="${flash.message}">
		        <div class="message">${flash.message}</div>
		    </g:if>

	        <p>We are looking for talented Java Developers.</p>
	        <p>See our recruitment advertising <a href="http://www.gomobile.co.id/open_recruitment">here</a> and the top three will get a new BlackBerry Bold!</p>

	        <br/>

            <g:ifLoggedIn>
                <% def assignment = (assignmentInstanceList.find { id = 1}) %>
                <g:if test="${assignment}">
                    If you are eager to take the test again, don't hesitate to contact Administrator to reassign the test for you. 
                </g:if>
                <g:else>
	                If you are ready to take the test, click the button below!<br/><br/>
	                <g:form controller="assignment" action="selfAssign">
	                   <g:hiddenField name="test.id" value="1" /> <%-- Hardcoded ID --%>
	                   <g:hiddenField name="user.id" value="${userInstance?.id}" /> <%-- Hardcoded ID --%>
	                   <g:submitButton name="submit" value="I am ready!"/>
	                </g:form>
                </g:else>
	        </g:ifLoggedIn>
	        <g:ifNotLoggedIn>
	        <p><g:link controller="registration" action="signup">Sign up here</g:link> to and take our test online.</p>
	        <p>If you have been registered before, please <g:link controller="login">login</g:link> and take the exam.</p>
	        </g:ifNotLoggedIn>

            <br/>
            <br/>

	        <g:if test="${newAssignmentInstanceList}">

            <h3>
            Assignments
            </h3>

	        <div class="list">
	        <table>
	            <col width="50" />
	            <col />
	            <col width="175" />
	            <col width="100" />
	            <col width="100" />
	            <col width="150" />
	            <thead>
	                <tr>
	                    <th title="Mo">#</th>
	                    <th title="Test">Test</th>
	                    <th title="Number of Items">Assignment Time</th>
	                    <th title="Number of Items">Number of Items</th>
	                    <th title="Number of Items">Timeout (Minutes)</th>
   	                    <th title="Action">Action</th>
	                </tr>
	            </thead>
	            <tbody>
	            <g:each in="${newAssignmentInstanceList}" status="i" var="assignmentInstance">
	                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
	                    <td>${i+1}</td>
	                    <td><g:link controller="test" action="show" id="${assignmentInstance?.test?.id}">${assignmentInstance?.test?.name}</g:link></td>
	                    <td><g:formatDate date="${assignmentInstance?.dateCreated}" type="datetime" style="MEDIUM" timeStyle="MEDIUM"/></td>
	                    <td>${assignmentInstance?.items?.size()}</td>
	                    <td>${assignmentInstance?.test?.preference?.timeout}</td>
	                    <td style="text-align: center">
	                        <g:form controller="main" action="start" id="${assignmentInstance?.id}" style="display: inline">
		                        <g:if test="${assignmentInstance?.startTime}"><input type="submit" name="start" value="Continue" /></g:if>
                                <g:else><input type="submit" name="start" value="Start" /></g:else>
   	                        </g:form>
	                    </td>
	                </tr>
	            </g:each>
	            </tbody>
	        </table>
	        </div>
	        
	        </g:if>
		</div>
    </body>
</html>